/**
 * 
 */
package org.dragonfire.dasm.directives;

import java.util.ArrayList;

import org.dragonfire.dasm.Command;
import org.dragonfire.dasm.CompileException;
import org.dragonfire.dasm.Listing;
import org.dragonfire.dasm.DirectiveManager.Directive;

/**
 * Generates an error with a custom error message<br />
 * <br />
 * Format:<br />
 * <code>#ERROR <i>&lt;arg1&gt;</i>[,<i>&lt;arg2&gt;</i>[,<i>...</i>]]</code><br />
 * <br />
 * Parameters:<br />
 * <table>
 * <tr>
 * <td><code>arg1</code></td>
 * <td> (Double/String) The string or number to print out as an error message</td>
 * </tr>
 * </table><br />
 * Errors:<br />
 * <i>None</i>
 * 
 * @see org.dragonfire.dasm.DASM#error(CompileException)
 * @see org.dragonfire.dasm.DASM#error(String, Object...)
 * @author Darth Android
 * @version 2.0
 */
public class Error extends Directive {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public ArrayList<Listing> pass1(Command c) {
		String message = "";
		// build the message
		for (int i = 0; i < c.getParams().length; i++) {
			message += evalString(c.getParam(i));
		}
		throw new CompileException("LANG_UNTRANSLATED", message);
	}
}
